home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
commio0b.zip
/
COMMIO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-05-20
|
56KB
|
1,560 lines
{$X+,A+,V-,R-,S-,O-,B-}
unit commio;
{
This is the Main Communications unit (COMMIO)
Written by Jason Morriss aka. Lief O'Pardy; (started on 7/26/95)
Copyright (C) 1995,1996 by Jason Morriss
Some real documentation will be written at a later date, for now you'll
just have to look at the procedure/function headers to see what each
routine does.
I will try to describe how to use these routines to setup any type of door
program for use on a BBS (a better description will be given when the DOC's
are written):
1) Get any and all information that you need about the USER and BBS when
your door starts. You need this information so you can setup the USER
and BBS variables. For instance, You need to know if the user is using
ANSI or not, what node s/he is on, etc... As for the BBS (this is most
important, without this step your door will probably not work at all
and will probably freeze the BBS), you need to find out what Comport
and the Baudrate the user is connected at, without this you cannot
communicate with the user at the remote end.
Either use a DROPFILE (the routines for this are not completed yet),
The command line, or an INI file...
Bare minimum get the Comport, Baudate, WhichIO (fossil, internal) and
MaxTimeAllowed!
2) Once all the important info has been put into the "DOOR" record (look
below for the door record), Make a call to the InitComport function.
If that function returns true then all is alright and you can continue,
otherwise you should halt the door so the BBS can take control again.
Then call InstallAllTasks so that the Timing variables will be setup,
and then you can forget about them. The user will be automatically
booted out if his/her time runs out. You can also optionally call
ShowStatusBar. This procedure displays a Statusbar at the bottom of
the screen. With info on the user, connection, local env., and time
remaining (Pressing F2 while in the DOOR will show the status line too).
3) You should now be able to do anything you want with your door. enjoy.
4) Most door libraries require you to call a certain procedure to DE-Init
the comport, etc... You dont have to do a thing with this library!
Just let your program exit normally. Look in the "_EXIT" unit for more
details. Its all done automatically, it wont hurt if you do call the
Deinitcomport() though...
}
interface
uses _exit, crt, dos, async, fosunit, mtask;
type
Tscreen = array[0..24,0..159] of byte;
TSystemEnv = (NoTasker{,DOS5},DDOS,DV,WIN,OS2,NetWare);
TWhichIO = ({LocalIO,}FossilIO,InternalIO);
TCharAry = array[0..0] of char;
string40 = string[40];
string12 = string[12];
{v- anything with an (R) in front of it, is READ ONLY; do not write to them
in your own door code.}
Tdoor = record (* Record for the more common "DOOR-System" variables *)
UserName : string[40];{user's name; could be alias or real}
{------------------------}
ComPort : byte; {Which Comport the program is using; 0=local}
Baudrate : longint; {Baudrate for the comport}
WhichIO : TWhichIO; {Which IO routines to use; fossil or internal}
IOinstalled : boolean; {comport IO routines installed?}
InBufSize : word; {Input buf size. (only for internal routines)}
OutBufSize : word; {Output buf size. (only for internal routines)}
IRQ : byte; {Which IRQ is being used}
WordSize : byte; {Wordsize (databits) for comport}
Parity : char; {parity for comport; 'N'=none 'E'=even 'O'=odd}
StopBits : byte; {stopbits for comport}
node : byte; {Which node the user is on (on BBS)}
{------------------------}
UseAnsi : boolean; {Is ansi used or not?}
{^ Even if in local mode, this must be true in order to use commands
that would use ANSI to the remote user. }
UseColor : boolean; {Is color used or not?}
UseAni : boolean; {Is animation used or not? (see putstr in doorio)}
SmartColor : boolean; {"Smart" mode ON/OFF for ansi color code sending}
LocalInputON: boolean; {Enable/Disable local keyboard input}
UpdateLocal : boolean; {Writes to the local screen are allowed or not?}
{R} UpdateStatusBar:boolean; {update status bar? (even if updatelocal=false)}
{R} UseVirtScr : boolean; {Use the virtual screen?}
StatusBarY : byte; {What line the status bar is displayed on}
LocalMaxY : byte; {# of lines (1-#) to update on local screen (usually 25)}
{------------------------}
{R} CurTime : DateTime; {Current Time. Updated consistently; 24h format}
SecsLeft : longint; {Seconds left until user is booted back to BBS}
{R} SecsOn : longint; {how long the user has been in the door}
KickOffIdle : integer;
{^# of secs the user can be idle before he gets booted back to the bbs.
This will "beep" the user once when the Idle Time is <= 30 seconds.
A value of -1 will disable the Auto-KickOff feature. (this variable
does not get decremented "CurIdle" does).}
{R} LocalKey : boolean; {Was the last key pressed local?}
OnLine : boolean; {Is user online/connected?}
PauseLine : byte; {# of lines to display before pausing output; 24=default}
{^ will probably be taken out.}
CurLine : byte; {Current line counter}
{^ will probably be taken out; use "virty" instead.}
{------------------------}
end;
const
CurIdle : integer = 0; {Idle counter for auto-kickoff feature}
IdleStart : longint = 0;
MaxTimeAllowed : word = 24*60; {Maximum time allowed in DOOR; in MINUTES}
{^ 2*60 = 2 hours.}
var
MacroStr : string; { Macro string; used in readkey funcs. }
door : tdoor; { "door-system" variables }
StartTime : datetime; { when user entered door }
SystemEnv : tsystemenv; { What OS is operating locally? }
KickedOut : boolean; { was user kicked out? (F6) }
Beeped : boolean;
const {virtual screen variables}
VirtScr : ^tscreen = nil; { Virtual Screen }
VirtX : integer = 1; { Virtual X screen position for cursor }
VirtY : integer = 1; { Virtual Y screen position for cursor }
{^ even if the virtual screen is not initialized, the VirtX/Y variables are
used to determine where the cursor is.
Anytime you want to know where the cursor is, use these variables. Do
NOT use WhereX/Y... sometimes you'll get the wrong result.}
var
SkipReadkey : boolean;
{^ special variable. if true, and the sysop pushes a syskey then; the
sioreadkey function will call the syskey function and then exit the
sioreadkey function itself, returning a nul (#0) char, then continuing
with the program. Its hard to explain. I needed this for the file
displaying file routines. you will never have to mess or even look at
this variable while programming (unless you really, really want too ;)}
{─--[headers]-──────────────────────────────────────────────────────────────}
Function InitComport:boolean;
{^ Initializes the comport for IO. This is normally the 2nd thing that is
called when your door starts (the 1st thing would either be reading a
DropFile, or INI file, or both). This must be called before any of the
other comport IO routines are called! (any procs. that use the modem). No
params are needed... because all the values needed are taken from the
"door" record (port,baud,parity), So the DOOR var must be setup first. }
Procedure DeInitComport;
{^ DeInitializes the comport. You can call this at the end of your door, but
you don't have to. It will be called automatically on its own at the end
of the program, its better if you don't call it.
(see also: AddToExi